package larkvadcheck.com.myrxtools;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.animation.Animation;
import android.widget.Button;

import com.vondear.rxtools.view.dialog.RxDialogSure;


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final RxDialogSure rxDialogSure = new RxDialogSure(MainActivity.this,R.layout.test);//提示弹窗
        final View mContentView=rxDialogSure.getContentView();
        findViewById(R.id.bt_Sure).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                setAnimation(mContentView);
                rxDialogSure.show();
            }
        });
        mContentView.findViewById(R.id.bt_Close_RedPackage).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                rxDialogSure.dismiss();
            }
        });

       final Button bt_Open_RedPackage =(Button) mContentView.findViewById(R.id.bt_Open_RedPackage);
        bt_Open_RedPackage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                setRotateY3DAdmin(bt_Open_RedPackage);
            }
        });

    }

    private void setRotateY3DAdmin(View view)
    {
        float centerX = (float) view.getWidth()/2;
        float centerY = (float) view.getHeight()/2;
        RotateY3DAdmin rotateY3DAdmin = new RotateY3DAdmin(centerX,centerY);
        rotateY3DAdmin.setDuration(600);
        rotateY3DAdmin.setRepeatCount(Animation.INFINITE);
        view.startAnimation(rotateY3DAdmin);
    }
    private void setAnimation(View imageView)
    {
        //沿x轴放大
        ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(imageView, "scaleX", 0.1f, 1.5f, 1f);
        //沿y轴放大
        ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(imageView, "scaleY", 0.1f, 1.5f, 1f);
        //移动
       // ObjectAnimator translationXAnimator = ObjectAnimator.ofFloat(imageView, "translationX", 0f, 200f, 0f);
        //透明动画
        ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, "alpha", 0.7f, 0.9f, 1f);
        AnimatorSet set = new AnimatorSet();
        //同时沿X,Y轴放大，且改变透明度，然后移动
        set.play(scaleXAnimator).with(scaleYAnimator).with(animator);
        //都设置3s，也可以为每个单独设置
        set.setDuration(2000);
        set.start();
    }
}
